package Code.StringCompare;

import java.util.Scanner;

/*用户登录
需求：已知正确的用户名和密码，请用程序实现模拟用户登录。
总共给三次机会，登录之后，给予相应的提示
 */
public class Test {
    public static void main(String[] args) {
        String id= "1337153934";
        String password = "wangheng6";

        Scanner scanner = new Scanner(System.in);

        for (int i = 0; i < 3; i++) {
            System.out.println("请输入账号：");
            String newId = scanner.next();
            System.out.println("请输入密码：");
            String newPassword = scanner.next();

            if (newId.equals(id)&&newPassword.equals(password)){
                System.out.println("登录成功！");
                break;
            }else {
                if (i ==2){
                    System.out.println("账号已被锁定");
                }else {
                    System.out.println("账号或密码错误，请重新输入！");
                    System.out.println("还有"+(2-i)+"次机会");
                }
            }

        }
    }
}
